package com.star.wellconnect.sqlite;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.util.Log;

public class Appointment {
	private int id;
	public String name;
	public String doctor;
	public String date;
	public String time;
	public String address;
	public String notes;
	
	public Appointment(int apptId, String name, String doctor, String date,
			String time, String address, String notes){
		this.id = apptId;
		this.name = name;
		this.doctor = doctor;
		this.date = date;
		this.time = time;
		this.address = address;
		this.notes = notes;
	}
	
	public int getID(){
		return id;
	}
	
	public String getDate(String format){
		DateFormat sdf = new SimpleDateFormat(AppPreferences.SQL_DATE, Locale.US);
		Date date;
		String retVal = this.date;
		
		try {
			date = sdf.parse(this.date);
			sdf = new SimpleDateFormat(format, Locale.US);
			retVal = sdf.format(date);
		} catch (ParseException e) {
			Log.e("GetDate", e.getMessage());
		}
		return retVal;
	}
	
	public String getTime(String format){
		DateFormat sdf = new SimpleDateFormat(AppPreferences.MILITARY_TIME, Locale.US);
		Date date;
		String retVal = this.time;
		
		try {
			date = sdf.parse(this.time);
			sdf = new SimpleDateFormat(format, Locale.US);
			retVal = sdf.format(date);
		} catch (ParseException e) {
			Log.e("getTime", e.getMessage());
		}
		return retVal;
	}
}
